﻿using System.IO;
using Loki.Engine;
using Luna.Connectors;
using Luna.Data.Configuration;
using Luna.Data.CRM;
using Luna.Data.SqlServer;

namespace Luna.Data.Test
{
    public class SqlServerTestDataModel : ObjectModel, IDataContext
    {
        private const string TEST_FILE = "testdatabase.mdf";
        private const string TEST_FILE_LOG = "testdatabase_log.ldf";

        public Budget.IBudgetProvider Budget
        {
            get { throw new System.NotImplementedException(); }
        }

        public IConfigurationProvider Configuration
        {
            get { throw new System.NotImplementedException(); }
        }

        public System.Collections.Generic.IDictionary<ConnectorType, IConnector> Connectors
        {
            get { throw new System.NotImplementedException(); }
        }

        public IContactProvider Contacts
        {
            get { throw new System.NotImplementedException(); }
        }

        public void Clean()
        {
            InternalContext.Dispose();
            File.Delete(TEST_FILE);
        }

        protected override void InternalLoad()
        {
            base.InternalLoad();

            DatabaseInstaller.SqlServer.Install(InternalContext);

            DataInstallers.All.Install(InternalContext);

            var L_ConfigProvider = InternalContext.Resolve<IConfigurationProvider>();
            L_ConfigProvider.CreateNewStore(TEST_FILE);
        }
    }
}